package com.atguigu.tingshu.live.api;

import com.atguigu.tingshu.common.anno.AuthLogin;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.live.service.LiveRoomService;
import com.atguigu.tingshu.model.live.LiveRoom;
import com.atguigu.tingshu.vo.live.LiveRoomVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("api/live/liveRoom")
@SuppressWarnings({"unchecked", "rawtypes"})
public class LiveRoomApiController {

	@Autowired
	private LiveRoomService liveRoomService;

// 	/api/live/liveRoom/getCurrentLive
	@AuthLogin
	@GetMapping("/getCurrentLive")
	public Result<LiveRoom> getCurrentLive(){
		return Result.ok(liveRoomService.getCurrentLive());
	}

// 	/api/live/liveRoom
	@AuthLogin
	@PostMapping("/saveLiveRoom")
	public Result<LiveRoom> saveLiveRoom(@RequestBody LiveRoomVo liveRoomVo){
		return Result.ok(liveRoomService.saveLiveRoom(liveRoomVo));
	}

// 	/api/live/liveRoom/getById/4
	@AuthLogin
	@GetMapping("/getById/{roomId}")
	public Result<LiveRoom> getById(@PathVariable Long roomId){
		return Result.ok(liveRoomService.getById(roomId));
	}
// 	/api/live/liveRoom/findLiveList
	@AuthLogin
	@GetMapping("/findLiveList")
	public Result<List<LiveRoom>> findLiveList(){
		return Result.ok(liveRoomService.findLiveList());
	}


}

